﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using ValidationEngine.Commons.Interfaces;

namespace ValidationEngine.Commons
{
    /// <summary>
    /// Control bindings scanner interface
    /// </summary>
    internal interface IViewMgr
    {
        /// <summary>
        /// Scans IBindableView for controls to build BindableItem collection
        /// </summary>
        /// <param name="view">View to scan</param>
        void ScanControls(IBindableView view);

        /// <summary>
        /// Returns control bound to model's property
        /// </summary>
        /// <param name="modelType">Model type.</param>
        /// <param name="propertyName">Model's property name.</param>
        /// <returns></returns>
        IEnumerable<Control> GetControlsByModelProperty(Type modelType, string propertyName);

        /// <summary>
        /// Returns binding source control bound to.
        /// </summary>
        /// <param name="ctrl">Bound control.</param>
        /// <returns>BindingSource instane if found. Other way NULL is returned.</returns>
        BindingSource GetSourceByControl(Control ctrl);

        /// <summary>
        /// Resets scaned controls sources bindings
        /// </summary>
        void ResetAllBindings();

        /// <summary>
        /// Sets validation info for displaying errors for control
        /// </summary>
        /// <param name="ctrl">Control</param>
        /// <param name="info">Validation info</param>
        void SetValidationInfoForControl(Control ctrl, IValidationInfo info);
    }
}
